/**
 * @Author: wangliuyang
 * @Date: 2021/8/17 21:12
 * @Description:
 */
public class Solution_121 {
        public int maxProfit(int[] prices) {
            int ans = Integer.MIN_VALUE;
            int min = prices[0];
            for (int i = 0; i < prices.length; i++) {
                min = Math.min(min,prices[i]);
                ans = Math.max(ans,prices[i] - min);
            }
            return ans;
        }
}
